package com.bdqn.petmalldemo.utils;


import com.bdqn.petmalldemo.common.SystemConstants;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 *
 *@Author:彭俊
 *@description:分页工具类
 *@date:2020-03-11 15:16
 *
 */
public class PageUtils implements Serializable {
    private static final long serialVersionUID = -2503029795083908037L;

    private Integer total;

    private Integer totalPage;

    private Integer startIndex;

    private Integer currentPage;

    private Integer pageSize= SystemConstants.PAGE_SIZE;

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getStartIndex() {
        startIndex= StringUtils.isEmpty(currentPage)||Integer.valueOf(0).equals(currentPage)?0:
                (currentPage - 1)* SystemConstants.PAGE_SIZE;
        return startIndex;
    }

    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

}
